https://samedwardes.com/blog/2022-10-23-best-jupyter-lab-install/ reference
Jupyter Basic Environment Creation and Customization
Part 1: Making a Python Kernel Available in Jupyter (Installed via pipx)
Install Jupyter via pipx (Already done):
bash1
2pipx install jupyter --include-deps
pipx ensurepathalternative:
pipx install pretzelai
pipx ensurepathSet Up a Python Virtual Environment for the Kernel:
bash1
python3.12 -m venv ~/venvs/python3.12
Activate the Virtual Environment:
bash1
source ~/venvs/python3.12/bin/activate
Install ipykernel in the Virtual Environment:
bash1
pip install ipykernel
Add the Kernel to Jupyter:
bash1
python -m ipykernel install --user --name python3.12 --display-name "Python 3.12"
Deactivate the Virtual Environment:
bash1
deactivate
Part 2: Customizing JupyterLab for a Better Workflow (With pipx)
1. Install JupyterLab Extensions with Pipx
1 | pipx install jupyter --include-deps |
Other Tips
in order to use %%ai magic command
, you will need to install in separate kernel this:
pip install jupyter_ai_magics
another option is to manually install JupyAI
also codeium auto code completion is availabe from codeium
jupyterlab-mutableai can change jupyter code to production code
install jupyterlab-execute-time which can show execution time
in view tab, check the line number
jupyterlabcodetoc can be useful
Pretzel Commands
1 | pipx runpip pretzelai install jupyter |
2. Using the Built-in Terminal and File Explorer
JupyterLab comes with built-in support for a terminal and file explorer, allowing you to manage files and run shell commands directly within the interface.
- Open a terminal: Go to
File > New > Terminal
to open a terminal inside JupyterLab. - Use the file explorer: The file browser on the left sidebar can be used to open, move, rename, or delete files directly within the JupyterLab environment.
Important Notes:
- Rebuild JupyterLab after installing extensions:bash
1
pipx run jupyter lab build
- Verify extensions:bash
1
pipx run jupyter labextension list
3. Enable an Extension
bash1
pipx run jupyter labextension enable @jupyterlab/notebook-extension:language-server
disable:
1 | pipx run jupyter labextension disable @jupyterlab/notebook-extension:language-server |
Jupyter Kernel Management
Kernel Specification (kernelspec) System
Kernel Spec Locations
Check kernel spec locations:
1 | jupyter kernelspec list |
How Kernels Are Registered
1 | python -m ipykernel install --user --name mypython --display-name "Python 3.12" |
Remove an Old Kernel
1 | jupyter kernelspec uninstall old-env |
Example: Adding Python 3.12 as a Kernel to Pipx Jupyter
Create a Virtual Environment for Python 3.12:
bash1
python3.12 -m venv ~/venvs/python3.12
Activate the Environment:
bash1
source ~/venvs/python3.12/bin/activate
Install ipykernel in the Environment:
bash1
pip install ipykernel
Add the Kernel to Jupyter:
bash1
python -m ipykernel install --user --name python3.12 --display-name "Python 3.12"